package com.jinlia.show.modules.system.controller;

import com.jinlia.show.modules.base.model.po.GoodsAttrPO;
import com.jinlia.show.modules.base.system.service.GoodsAttrMapperService;
import com.jinlia.show.modules.base.utils.PayOrderNumGenerator;
import com.jinlia.show.modules.system.model.forms.GoodsAttrForm;
import com.jinlia.show.modules.system.service.GoodsAttrService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("goodsAttr")
public class GoodsAttrController {
    @Autowired
    private PayOrderNumGenerator payOrderNumGenerator;
    @Autowired
    GoodsAttrMapperService goodsAttrMapperService;

    @Autowired
    GoodsAttrService goodsAttrService;
    @GetMapping("/list/{goodsId}")
    public List<GoodsAttrPO> getById(@PathVariable("goodsId") Long goodsId) {
        List<GoodsAttrPO> pOsByGoodsId = goodsAttrMapperService.getPOsByGoodsId(goodsId);
        return pOsByGoodsId;
    }

    @PostMapping("addOrUpdate")
    public GoodsAttrForm addOrUpdate(@RequestBody GoodsAttrForm goodsAttrForm) {
        return  goodsAttrService.addOrUpdate(goodsAttrForm);
    }
    @PostMapping("del")
    public GoodsAttrForm del(@RequestBody GoodsAttrForm goodsAttrForm) {
        return  goodsAttrService.del(goodsAttrForm);
    }

}
